package management.tranHistory.dataObjects
{
	import mx.collections.ArrayCollection;
	import common.utils.DateManager;
	
	[Bindable]
	public class TransactionHistoryDO
	{	
		public var INTERNAL_ID:String = "0";
		public var TRANSACTION_TYPE:String = "";
		public var WAREHOUSE:String = "";
		public var ZONE:String = "";
		public var LOCATION:String = "";
		public var LPN:String = "";
		public var ITEM:String = "";
		public var ITEM_DESC:String = "";
		public var COMPANY:String = "";
		public var ATTRIBUTE_NUM:String = "0";
		public var QUANTITY:String = "";
		public var QUANTITY_UM:String = "";
		public var TASK_ID:String = "";
		public var TASK_TYPE:String = "";
		public var REFERENCE_ID:String = "";
		public var REFERENCE_NUM:String = "0";
		public var REFERENCE_NUM_TYPE:String = "";
		public var REFERENCE_LINE_NUM:String = "0";
		public var BEFORE_ON_HAND_QTY:String = "0";
		public var AFTER_ON_HAND_QTY:String = "0";
		public var BEFORE_STS:String = "";
		public var AFTER_STS:String = "";
		public var DIRECTION:String = "";
		public var USER_STAMP:String = "";
		public var DATE_TIME_STAMP:String = DateManager.GetTodayString();

		public function TransactionHistoryDO()
		{
		}

		public function Init(xmlObj:XML):void{		
			if(null == xmlObj)
				return;
			else{
				for each (var itemProp:XML in xmlObj.children()) {
					//Use XML node name to reference matching property in value object				
					this[itemProp.name()] = itemProp;
				}
			}
		}
		
		public function ToXML():XML{
			var xmlObj:XML = 
				<TRANSACTION_HISTORY>
					<INTERNAL_ID>{INTERNAL_ID}</INTERNAL_ID>
					<TRANSACTION_TYPE>{TRANSACTION_TYPE}</TRANSACTION_TYPE>
					<WAREHOUSE>{WAREHOUSE}</WAREHOUSE>
					<ZONE>{ZONE}</ZONE>
					<LOCATION>{LOCATION}</LOCATION>
					<LPN>{LPN}</LPN>
					<ITEM>{ITEM}</ITEM>
					<ITEM_DESC>{ITEM_DESC}</ITEM_DESC>
					<COMPANY>{COMPANY}</COMPANY>
					<ATTRIBUTE_NUM>{ATTRIBUTE_NUM}</ATTRIBUTE_NUM>
					<QUANTITY>{QUANTITY}</QUANTITY>
					<QUANTITY_UM>{QUANTITY_UM}</QUANTITY_UM>
					<TASK_ID>{TASK_ID}</TASK_ID>
					<TASK_TYPE>{TASK_TYPE}</TASK_TYPE>
					<REFERENCE_ID>{REFERENCE_ID}</REFERENCE_ID>
					<REFERENCE_NUM>{REFERENCE_NUM}</REFERENCE_NUM>
					<REFERENCE_NUM_TYPE>{REFERENCE_NUM_TYPE}</REFERENCE_NUM_TYPE>
					<REFERENCE_LINE_NUM>{REFERENCE_LINE_NUM}</REFERENCE_LINE_NUM>
					<BEFORE_ON_HAND_QTY>{BEFORE_ON_HAND_QTY}</BEFORE_ON_HAND_QTY>
					<AFTER_ON_HAND_QTY>{AFTER_ON_HAND_QTY}</AFTER_ON_HAND_QTY>
					<BEFORE_STS>{BEFORE_STS}</BEFORE_STS>
					<AFTER_STS>{AFTER_STS}</AFTER_STS>
					<DIRECTION>{DIRECTION}</DIRECTION>
					<USER_STAMP>{USER_STAMP}</USER_STAMP>
					<DATE_TIME_STAMP>{DATE_TIME_STAMP}</DATE_TIME_STAMP>
				</TRANSACTION_HISTORY>;
			return xmlObj;
		}

		public static function getTransactionHistories(list:XMLList):ArrayCollection
		{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var xml:XML in list)
			{
				var attrDO:TransactionHistoryDO = new TransactionHistoryDO();
				attrDO.Init(xml);
				ac.addItem(attrDO);
			}
			return ac;
		}			
	}
}